package cn.lhn.ridersclub.mapper;

import cn.lhn.ridersclub.entity.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper extends BaseMapper<Comment> {

    @Select("select * from comment where id < ${startId} and paper_id = ${paperId} order by id desc limit 10;")
    List<Comment> listComment(@Param("paperId") Long paperId, @Param("startId") Long startId);

    @Select("select * from comment where account_id = ${accountId} and paper_id = ${paperId} order by id desc limit 1;")
    Comment getLastCommentForPaper(@Param("accountId") Long accountId, @Param("paperId") Long paperId);
}
